package com.mcxx.modules.miniSalvation.order.service.read;

import com.mcxx.common.exception.BizException;
import com.mcxx.modules.base.utils.QueryParamUtil;
import com.mcxx.modules.miniSalvation.order.dao.read.AreaMoveReadDao;
import com.mcxx.modules.miniSalvation.order.dto.AreaMoveDTO;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@TaTransactional(readOnly = true)
@Service
public class AreaMoveReadService {

    @Autowired
    private OrderReadService orderReadService;
    @Autowired
    private AreaMoveReadDao areaMoveReadDao;


    
    public void getExistNoFinishIdcard(List<String> idcardList){
        List<String> existNoFinishIdcardList = orderReadService.getExistNoFinishIdcard(idcardList);
        if(null != existNoFinishIdcardList && existNoFinishIdcardList.size() > 0){
            throw new BizException("-1", "家庭【" + String.join(",", existNoFinishIdcardList) + "】存在未办结的业务，不能迁移");
        }
    }

    
    public Page getBatchMigrationList(AreaMoveDTO areaMoveDTO, PageParam pageParam, UserAccountVo userAccountVo) {
        QueryParamUtil.setBaseParamValue(areaMoveDTO, userAccountVo);
        areaMoveReadDao.beginPager(pageParam);
        return areaMoveReadDao.endPager(areaMoveReadDao.queryMoveDetail(areaMoveDTO));
    }

    public AreaMoveDTO orderGetAreaMove(AreaMoveDTO areaMoveDTO){
        return areaMoveReadDao.orderGetAreaMove(areaMoveDTO);
    }
}
